package com.example.module;

import lombok.Data;

@Data
public class ListNode {
    int val=-1;
    ListNode next;

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    public void addNode(ListNode node, int val) {
        while (node != null) {
            if(node.getNext() !=null){
                addNode(node.getNext(),val);
                break;
            }
           if(node.getVal()==-1){
               node.setVal(val);
           }else {
               ListNode nextNode =new ListNode();
               nextNode.setVal(val);
               node.setNext(nextNode);
           }
            break;
        }
    }

}